package problem230;

//230.二叉搜索树中第k小的元素
//https://leetcode.cn/problems/kth-smallest-element-in-a-bst/

class Solution {
    int ret = 0, count = 0;
    public int kthSmallest(TreeNode root, int k) {
        if(root.left != null) kthSmallest(root.left, k);
        count++;
        if(count == k) ret = root.val;
        if(root.right != null) kthSmallest(root.right, k);
        return ret;
    }
}